package com.kingviker.example.nio;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 *  read-only Buffer
 */
public class NioTest7 {
    public static void main(String[] args) throws IOException {
       ByteBuffer byteBuffer = ByteBuffer.allocate(10);

       for(int i=0;i<byteBuffer.capacity();i++){
            byteBuffer.put((byte)i);
       }

       ByteBuffer readOnlyBuffer = byteBuffer.asReadOnlyBuffer();
        System.out.println(readOnlyBuffer.getClass());
        readOnlyBuffer.position(0);
        readOnlyBuffer.put((byte) 4);
   }
}
